﻿@model MODEL.EsDetail
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/bootstrapCss/bootstrap.min.css" rel="stylesheet" />
    <title>添加</title>
    <script src="~/Scripts/jquery-1.8.2.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.metadata.js"></script>
</head>
<body style="font-family:'Microsoft YaHei'">

    <div class="container">
        <h2>添加</h2>
        <div class="container">
            @using (Html.BeginForm("Add", "EsDetail", FormMethod.Post, new { @id = "publishForm", @class = "form-horizontal", @style = "width:100px;" }))
            {
                <div class="form-group">
                    <span>分类    :</span>
                    @Html.DropDownListFor(q => q.cateFirstId, ViewBag.firstIdItems as List<SelectListItem>, new { @id = "firstIdItems", @required = "true", @class = "form-control {required:true}", @style = "width:300px;" })
                </div>
                <div id="second" style="display:none">
                    <select id="secondIdItems" name="secondIdItems" class="form-control">
                        <option value="">-请选择-</option>
                    </select>
                </div>
                <br />
                <div id="third" style="display:none">
                    <select id="thirdIdItems" name="thirdIdItems" class="form-control">
                        <option value="">-请选择-</option>
                    </select>
                </div>


                <div class="form-group">
                    <span>新旧   :</span>
                    @Html.DropDownListFor(q => q.oldNew, ViewBag.xinjiu as List<SelectListItem>, new { @class = "form-control {required:true}" })
                </div>
                <div class="form-group">
                    <span>转让价格</span>
                    @Html.TextBoxFor(q => q.price, new { @class = "form-control", @style = "width:100px;" })
                </div>
                <div class="form-group">
                    <span>物品图片</span>
                    <input class="btn btn-primary" value="上传图片" type="button" />
                </div>
                <div class="form-group">
                    <span>标题</span>
                    @Html.TextBoxFor(q => q.title, new { @class = "form-control", @style = "width:400px;" })
                </div>
                <div class="form-group">
                    <span>详细说明</span>
                    @Html.TextAreaFor(q => q.description, new { @class = "form-control", @style = "width:600px;height:200px" })
                </div>
                <div class="form-group">
                    <span>联系人</span>
                    @Html.TextBoxFor(q => q.name, new { @class = "form-control}", @style = "width:150px;" })
                </div>
                <div class="form-group">
                    <span>联系电话</span>
                    @Html.TextBoxFor(q => q.telephone, new { @class = "form-control", @style = "width:150px;" })
                </div>
                <div class="form-group">
                    <span>qq</span>
                    @Html.TextBoxFor(q => q.qq, new { @class = "form-control", @style = "width:150px;" })
                </div>
                <input type="submit" class="btn btn-lg btn-success" value="提交啊" />
                <br />

            }
        </div>

        <form action="/" method="post" id="otherform">
            <input name="haha" type="text" />
            <input type="submit" value="sdjlfa" />
        </form>
    </div>
    <script>
        //级联菜单
        $(document).ready(function () {
            $("#publishForm").validate({
                rules: {
                    name: {required: true},
                    cateFirstId: { required: true },
                    secondIdItems: {required: true},
                    thirdIdItems:{required:true}
                },
                messages: {
                    cateFirstId: {
                        required:"请选择一项"
                    }
                }
            });

            $("#firstIdItems").change(function () {
                $("#thirdIdItems").empty();
                $("#secondIdItems").empty();
                $("#secondIdItems").append($("<option/>").text("-请选择-").attr("value", ""));
                $("#thirdIdItems").append($("<option/>").text("-请选择-").attr("value", ""));
                $.post("/EsDetail/Items", { type: "2", parentId: $("#firstIdItems").val() }, function (jsonData) {
                    $(jsonData.Data).each(function () {
                        $("#secondIdItems").append($("<option/>").text(this.name).attr("value", this.id));
                    });
                });
                console.log($("#firstIdItems").val());
                if ($("#firstIdItems").val() == "") {
                    $("#second").css("display", "none");
                    $("#third").css("display", "none");
                }
                else {
                    $("#second").css("display", "block");
                }
                if ($("#second").val() == "") {
                    $("#third").css("display", "none");
                }


            });
            $("#secondIdItems").change(function () {
                $("#thirdIdItems").empty();
                $("#thirdIdItems").append($("<option/>").text("-请选择-").attr("value", ""));
                $.post("/EsDetail/Items", { type: "3", parentId: $("#secondIdItems").val() }, function (jsonData) {
                    $(jsonData.Data).each(function () {
                        $("#thirdIdItems").append($("<option/>").text(this.name).attr("value", this.id));
                    });
                });
                if ($("#secondIdItems").val() == "") {
                    $("#third").css("display", "none");
                }
                else {
                    $("#third").css("display", "block");
                }
            });
        });
    </script>

</body>
</html>
